﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;

/// <summary>
/// Summary description for QLNhaCC
/// </summary>
public class QLNhaCC
{
    DBConnection db = new DBConnection();
	public QLNhaCC()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public DataTable Load_NCC()
    {
        string sql = "select * from nhacungcap";
        return db.Get_data(sql);
    }
    public void Insert_NCC(string tenncc,string diachi,string dt)
    {
        string sql = "insert into nhacungcap(tenncc,diachi,dienthoai) values(@tenncc,@diachi,@dienthoai)";
        SqlParameter p1 = new SqlParameter("@tenncc", tenncc);
        SqlParameter p2 = new SqlParameter("@diachi", diachi);
        SqlParameter p3 = new SqlParameter("@dienthoai", dt);
        db.thuchienlenh(sql, p1, p2, p3);
    }
    public DataTable Update_NCC(string mancc, string tenncc, string diachi, string dt)
    {
        string sql = "update nhacungcap set tenncc=@tenncc,diachi=@diachi,dienthoai=@dt where mancc=@mancc";
        SqlParameter p1 = new SqlParameter("@mancc", mancc);
        SqlParameter p2 = new SqlParameter("@tenncc", tenncc);
        SqlParameter p3 = new SqlParameter("@diachi", diachi);
        SqlParameter p4 = new SqlParameter("@dt", dt);
        return db.Get_data(sql, p1, p2, p3, p4);
    }
    public DataTable Delete_NCC(string mancc)
    {
        string sql = "delete from nhacungcap where mancc=@mancc";
        SqlParameter p1 = new SqlParameter("@mancc", mancc);
        return db.Get_data(sql, p1);
    }
}
